/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.cotec.model;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 *
 * @author magalhaes
 */
@Entity
@Table(name = "pessoa")
@NamedQueries({@NamedQuery(name = "Pessoa.findAll", query = "SELECT p FROM Pessoa p"), @NamedQuery(name = "Pessoa.findById", query = "SELECT p FROM Pessoa p WHERE p.id = :id"), @NamedQuery(name = "Pessoa.findByNome", query = "SELECT p FROM Pessoa p WHERE p.nome = :nome"), @NamedQuery(name = "Pessoa.findByEmail", query = "SELECT p FROM Pessoa p WHERE p.email = :email"), @NamedQuery(name = "Pessoa.findBySexo", query = "SELECT p FROM Pessoa p WHERE p.sexo = :sexo")})
public class Pessoa implements Serializable {
    private static final long serialVersionUID = 1L;
    
    public static final String FEMININO = "FEMININO";
    public static final String MASCULINO = "MASCULINO";
    public static final String SIGLA_MASCULINO = "M";
    public static final String SIGLA_FEMININO = "F";
   
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "nome", length=45)
    private String nome;
    @Column(name = "email", length=45)
    private String email;
    @Column(name = "sexo", length=1)
    private String sexo;
    
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "pessoa")
    private Contato contato;
    
    @OneToMany(mappedBy = "pessoaSolicitante")
    private List<Inbox> inboxList;
    @OneToMany(mappedBy = "pessoaResponsavel")
    private List<Inbox> inboxList1;
    @JoinColumn(name = "funcao", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Funcao funcao;
    @JoinColumn(name = "setor", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Setor setor;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "pessoa")
    private Users users = new Users();

    public Pessoa() {
    	this.setFuncao(new Funcao());
    	this.setSetor(new Setor());
    	this.setUsers(new Users());
    	this.setContato(new Contato());
    }

    public Pessoa(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getSexo() {
        return sexo;
    }

    public void setSexo(String sexo) {
        this.sexo = sexo;
    }

    public List<Inbox> getInboxList() {
        return inboxList;
    }

    public Contato getContato() {
		return contato;
	}

	public void setContato(Contato contato) {
		this.contato = contato;
	}

	public void setInboxList(List<Inbox> inboxList) {
        this.inboxList = inboxList;
    }

    public List<Inbox> getInboxList1() {
        return inboxList1;
    }

    public void setInboxList1(List<Inbox> inboxList1) {
        this.inboxList1 = inboxList1;
    }

    public Funcao getFuncao() {
        return funcao;
    }

    public void setFuncao(Funcao funcao) {
        this.funcao = funcao;
    }

    public Setor getSetor() {
        return setor;
    }

    public void setSetor(Setor setor) {
        this.setor = setor;
    }


    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    public Users getUsers() {
		return users;
	}

	public void setUsers(Users users) {
		this.users = users;
	}

	@Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Pessoa)) {
            return false;
        }
        Pessoa other = (Pessoa) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.cotec.model.Pessoa[id=" + id + "]";
    }

}
